<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        div.box {
            width: 100px;
            height: 100px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div class="box">
        good
    </div>
    <script>
        // 封装一个生成随机 RGB 颜色的函数
        function randomColor() {
            let r = Math.floor(Math.random() * 255);
            let g = Math.floor(Math.random() * 255);
            let b = Math.floor(Math.random() * 255);
            return `rgb(${r},${g},${b})`;
        }

        const tt = document.querySelector('div.box');
        tt.innerHTML = 'ss';
        // 通过 style 对象设置背景颜色
        tt.style.backgroundColor = randomColor();
        tt.style.width = '200px';
        tt.style.border = '1px solid red'
    </script>
</body>
</html>